home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Networking / Http Server / •Mac_Classes / TBackGroundApp.h < prev    next >
Encoding:
Text File  |  1996-01-11  |  3.0 KB  |  87 lines  |  [TEXT/CWIE]

  1. //    TBackGroundApp.h - Macintosh backround application object 
  2. // 
  3. // Apple Macintosh Developer Technical Support
  4. // Written by:  Vinne Moscaritolo
  5. //
  6. //  Copyright (work in progress)  Apple Computer, Inc All rights reserved.
  7. //
  8. // You may incorporate this sample code into your applications without
  9. // restriction, though the sample code has been provided "AS IS" and the
  10. // responsibility for its operation is 100% yours.  However, what you are
  11. // not permitted to do is to redistribute the source as "DSC Sample Code"
  12. // after having made changes. If you're going to re-distribute the source,
  13. // we require that you make it clear in the source that the code was
  14. // descended from Apple Sample Code, but that you've made changes.
  15. // 
  16.  
  17. #ifndef _H_TBACKGROUNDAPP
  18. #define _H_TBACKGROUNDAPP
  19.  
  20. #include <AppleEvents.h>
  21.  
  22. // ---------------------------------------------------------------------------
  23. //     TBackGroundApp - Background Application
  24. // ---------------------------------------------------------------------------
  25. // 
  26. class TBackGroundApp
  27. {
  28. public:
  29.     //    ENUMS AND TYPEDEFS
  30.     
  31.     enum  ESleepTimes{
  32.             kSleep_1_Min    = 3600,    // wake up every minute
  33.             kSleep_1_Sec    = 60,    // wake up every 1 Secs
  34.             kNoSleep        = 0};    //wake up every 0 seconds
  35.  
  36.     enum EAppCommands{
  37.             kAppQuit         = 1,
  38.             kAppOpen,
  39.             kAppOpenDocuments,
  40.             kAppPrint
  41.             };    
  42.             
  43.     enum EState {kSInit = 1, kSRun, kSQuit};
  44.  
  45. //     CONSTRUCTORS AND DESTRUCTORS
  46.              TBackGroundApp();
  47.      virtual ~TBackGroundApp();            
  48.  
  49. // MAIN INTERFACE
  50.     virtual void InitializeMemory();            // initialize our memory needs
  51.     virtual void InitializeToolbox();            // initialize the toolbox
  52.  
  53. // EVENT AND CONTROL METHODS
  54.     virtual void DoEventLoop();                    // handle the actual event dispatching
  55.     virtual void DoNextEvent();                    // handle the incoming events
  56.     virtual void DoHighLevelEvent();            // handle high level events
  57.  
  58.     virtual void Start();                        // start the application and let it run
  59.     virtual void DoIdle();                        // call idle handler
  60.     virtual void Quit();                        // quit the application 
  61.  
  62. // CORE AE HANDLER METHODS
  63.     virtual void  InstallAEHandler();                                    // install our AE dispatcher
  64.     virtual OSErr DispatchAppleEvents(AppleEvent*, AppleEvent* , long); // Dispatch incoming Apple Events in the framework
  65.     virtual OSErr HandleQuit (AppleEvent* , AppleEvent*, long );        // handle the quit AE
  66.     virtual OSErr HandleOpen (AppleEvent* , AppleEvent*, long );        // handle the open AE
  67.     virtual OSErr HandleOpenDocuments (AppleEvent*,AppleEvent*,long);    // handle the open document AE
  68.     virtual OSErr HandlePrint (AppleEvent*, AppleEvent*,long);            // handle the print command
  69.  
  70. // STATE CHANGE METHODS
  71.     virtual void SetState(TBackGroundApp::EState theState);        // change the state of the application FSM
  72.  
  73. // PRIVATE FIELDS
  74. protected:
  75.     EState             fState;                        // internal state of the TBackGroundApp
  76.     long            fSleepTime;                    // Multifinder WNE delay
  77.     EventRecord     fEventRecord;                // current event record
  78.  
  79. // CLASS VARIABLES
  80. public:
  81.     static     TBackGroundApp*    fgApplication;        // global pointer to background app
  82.  
  83. };
  84.  
  85. #endif
  86.  
  87.